package Main;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.JOptionPane;
/**
 *
 * @author Ziad Aloulou
 */
public class Evenements implements ActionListener {

    private Frame frame;
    private Bienvenue bienvenue;

    public Evenements(Frame frame, Bienvenue bienvenue) {
        this.frame = frame;
        this.bienvenue = bienvenue;
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
        if (ae.getSource() == bienvenue.btnPoker) {
            frame.mainPanel.removeAll();
            Poker.Affichage poker = new Poker.Affichage(frame);
            frame.mainPanel.add(poker);
        } else if (ae.getSource() == bienvenue.btnBlackJack) {
            frame.mainPanel.removeAll();
            try{
                pkgBlackJack.Blackjack BJ;
                BJ = new pkgBlackJack.Blackjack(frame, 450, 490);
                frame.mainPanel.add(BJ);
                }catch(IOException e){
                    System.out.println("fail");
                }
        } else if (ae.getSource() == bienvenue.btnRoulette) {
            frame.mainPanel.removeAll();
            pkgRoulette.Roulette roulette = new pkgRoulette.Roulette(frame);
            frame.mainPanel.add(roulette);
        } else if (ae.getSource() == bienvenue.btnSlots) {
            frame.mainPanel.removeAll();
            Slots.Console slots = new Slots.Console(frame);
            frame.mainPanel.add(slots);
            slots.display.setMessage("LFIAHF;AHSDG");
            System.out.println(slots.display.getMessage());
        } else if (ae.getSource() == frame.mnuQuitter) {
            System.exit(0);
        } else if (ae.getSource() == frame.mnuPrincipal) {
            frame.mainPanel.removeAll();
             frame.mainPanel.add(bienvenue);
             frame.setSize(615, 400);
        }else if (ae.getSource() == frame.mnuPropos) {
            JOptionPane.showMessageDialog(frame, "Programmé par: Ziad, Benoit et Vincent\n"
                                               + "     Développé par le casino VZB");
        }
        frame.getRootPane().revalidate();
        frame.repaint();
    }
}
